package com.wf.ew.storage.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.User;
import com.wf.ew.storage.biz.WarehouseBiz;
import com.wf.ew.storage.model.Warehouse;
import com.wf.ew.storage.service.WarehouseService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2019-11-18 12:36:43
 * @version ：1.0
 */
@Service
public class WarehouseServiceImpl implements WarehouseService {

	@Autowired
	private WarehouseBiz warehouseBiz;

	@Override
	public String list(PageResult<T> page, Warehouse warehouse, User loginUser) {
		return warehouseBiz.list(page,warehouse,loginUser);
	}
	
	@Override
	public List<Warehouse> list(Warehouse warehouse, User loginUser) {
		return warehouseBiz.list(warehouse,loginUser);
	}

	@Override
	public Warehouse getById(Warehouse warehouse) {
		return warehouseBiz.getById(warehouse);
	}

	@Transactional
	@Override
	public JsonResult add(Warehouse warehouse, User loginUser) {
		if (warehouseBiz.add(warehouse, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(Warehouse warehouse, User loginUser) {
		if (warehouseBiz.update(warehouse, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(Warehouse warehouse, User loginUser) {
		if (warehouseBiz.delete(warehouse, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
